package com.huawei.gamebox.plugin.gameservice.view;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import java.util.LinkedList;
import java.util.Queue;
import o.ayw;
import o.ayy;
import o.BaseAlertDialog;
import o.Logger;
import o.dof;
import o.fak;

public class GameServiceShowDialogActivity extends Activity {
    private Queue<String> ˊ;
    private BaseAlertDialog ˎ = null;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ayy.ˋ().ˎ(getWindow());
        if (Logger.ˎ()) {
            Logger.ˏ("GameServiceShowDialogActivity", "onCreate");
        }
        requestWindowFeature(1);
        ayw.ॱ(this);
        getWindow().setFlags(WXMediaMessage.DESCRIPTION_LENGTH_LIMIT, WXMediaMessage.DESCRIPTION_LENGTH_LIMIT);
        View view = new View(this);
        view.setAlpha(0.0f);
        setContentView(view);
        this.ˊ = new LinkedList();
        ˏ();
        ˋ();
    }

    protected void onNewIntent(Intent intent) {
        if (Logger.ˎ()) {
            Logger.ˏ("GameServiceShowDialogActivity", "deal with new Intent");
        }
        super.onNewIntent(intent);
        setIntent(intent);
        ˏ();
    }

    private void ˏ() {
        String stringExtra = getIntent().getStringExtra("dialogClass");
        if (dof.ˋ(stringExtra)) {
            if (Logger.ˎ()) {
                Logger.ˏ("GameServiceShowDialogActivity", "dialogClass is null");
            }
            finish();
        } else if (this.ˊ.offer(stringExtra)) {
            fak.ॱ(this, getIntent());
        } else {
            finish();
        }
    }

    private void ˋ() {
        if (Logger.ˎ()) {
            Logger.ˏ("GameServiceShowDialogActivity", "start to show dialog");
        }
        if (this.ˊ.isEmpty()) {
            if (Logger.ˎ()) {
                Logger.ˏ("GameServiceShowDialogActivity", "No dialog to show , activity finish");
            }
            finish();
            return;
        }
        try {
            this.ˎ = fak.ॱ((String) this.ˊ.poll());
        } catch (Exception e) {
            Logger.e("GameServiceShowDialogActivity", "fail to add dialog");
            finish();
        }
        if (this.ˎ != null) {
            this.ˎ.ˎ(new OnDismissListener(this) {
                final /* synthetic */ GameServiceShowDialogActivity ˊ;

                {
                    this.ˊ = r1;
                }

                public void onDismiss(DialogInterface dialogInterface) {
                    this.ˊ.ˎ = null;
                    if (Logger.ˎ()) {
                        Logger.ˏ("GameServiceShowDialogActivity", "dialog dismiss, start to show next");
                    }
                    this.ˊ.ˋ();
                }
            });
            this.ˎ.ॱ();
            return;
        }
        finish();
    }

    protected void onDestroy() {
        super.onDestroy();
        if (Logger.ˎ()) {
            Logger.ˏ("GameServiceShowDialogActivity", "onDestroy");
        }
        if (this.ˎ != null) {
            if (Logger.ˎ()) {
                Logger.ˏ("GameServiceShowDialogActivity", "dismiss the dialog");
            }
            this.ˎ.ˎ(null);
            this.ˎ.ˏ();
            this.ˎ = null;
        }
        fak.ˏ();
    }

    protected void onPause() {
        super.onPause();
        if (Logger.ˎ()) {
            Logger.ˏ("GameServiceShowDialogActivity", "onPause");
        }
    }
}
